package com.cn.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.cn.service.UserServiceInterface;
import com.opensymphony.xwork2.ActionSupport;
/**
 * 
 * @author Hang
 * @date 2016年2月24日下午2:43:51
 * @version
 */
@SuppressWarnings("serial")
@ParentPackage(value = "json-default")  //指定package的名字
@Namespace(value = "/user")
public class UserAction extends ActionSupport{
	
	private UserServiceInterface userServiceInterface;

	@Action(value = "userRegist", results = {
			@Result(name = "success", location = "/index.jsp"),
			@Result(name = "field", location = "/login.jsp")
	})
	public void userRegist(){
		
	}
	
	public void test(){
		System.out.println("Struts2成功");
		userServiceInterface.test();
		/*ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(ServletActionContext.getServletContext());
		UserServiceImpl userServiceImpl = (UserServiceImpl) ac.getBean("userService");
		userServiceImpl.test();*/
	}
	
	public UserServiceInterface getUserServiceInterface() {
		return userServiceInterface;
	}
	@Resource
	public void setUserServiceInterface(UserServiceInterface userServiceInterface) {
		this.userServiceInterface = userServiceInterface;
	}
	
}
